<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.14.0/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">

<script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Gemini","version":"8.0.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"Searching...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}};
  </script>

  <meta name="description" content="1.算术运算符：+，-，*，&#x2F;，%，++，–   2.位运算符：&amp;，|，~，^，&lt;&lt;，&gt;&gt;，&gt;&gt;&gt;(&lt;&lt;,&gt;&gt;,&gt;&gt;&gt;分别是左移，右移，无符号右移。左移空位用0填充；右移空位用符号位填充；无符号右移用0填充，因为用0填充，所以结果总是一个正数) (位运算符操作的是二进制数，将操作数转换二进制数后再进行运算，">
<meta property="og:type" content="article">
<meta property="og:title" content="Java运算符一览">
<meta property="og:url" content="http://yoursite.com/2020/07/19/Java%E8%BF%90%E7%AE%97%E7%AC%A6%E4%B8%80%E8%A7%88/index.html">
<meta property="og:site_name" content="lungyam&#39;s blog">
<meta property="og:description" content="1.算术运算符：+，-，*，&#x2F;，%，++，–   2.位运算符：&amp;，|，~，^，&lt;&lt;，&gt;&gt;，&gt;&gt;&gt;(&lt;&lt;,&gt;&gt;,&gt;&gt;&gt;分别是左移，右移，无符号右移。左移空位用0填充；右移空位用符号位填充；无符号右移用0填充，因为用0填充，所以结果总是一个正数) (位运算符操作的是二进制数，将操作数转换二进制数后再进行运算，">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-07-19T05:47:58.000Z">
<meta property="article:modified_time" content="2020-07-19T05:57:46.100Z">
<meta property="article:author" content="lungyam">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://yoursite.com/2020/07/19/Java%E8%BF%90%E7%AE%97%E7%AC%A6%E4%B8%80%E8%A7%88/">


<script class="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'en'
  };
</script>

  <title>Java运算符一览 | lungyam's blog</title>
  






  <noscript>
  <style>
  body { margin-top: 2rem; }

  .use-motion .menu-item,
  .use-motion .sidebar,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header {
    visibility: visible;
  }

  .use-motion .header,
  .use-motion .site-brand-container .toggle,
  .use-motion .footer { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle,
  .use-motion .custom-logo-image {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line {
    transform: scaleX(1);
  }

  .search-pop-overlay, .sidebar-nav { display: none; }
  .sidebar-panel { display: block; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">lungyam's blog</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>







</div>
        
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-overview-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <section class="post-toc-wrap sidebar-panel">
      </section>
      <!--/noindex-->

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">lungyam</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">7</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
  </nav>
</div>



      </section>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">
      

      

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/07/19/Java%E8%BF%90%E7%AE%97%E7%AC%A6%E4%B8%80%E8%A7%88/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="lungyam">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="lungyam's blog">
    </span>

    
    
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Java运算符一览
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>
      

      <time title="Created: 2020-07-19 13:47:58 / Modified: 13:57:46" itemprop="dateCreated datePublished" datetime="2020-07-19T13:47:58+08:00">2020-07-19</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <p>1.算术运算符：+，-，*，/，%，++，–  </p>
<p>2.位运算符：&amp;，|，~，^，&lt;&lt;，&gt;&gt;，&gt;&gt;&gt;<br>(&lt;&lt;,&gt;&gt;,&gt;&gt;&gt;分别是左移，右移，无符号右移。左移空位用0填充；右移空位用符号位填充；无符号右移用0填充，因为用0填充，所以结果总是一个正数)</p>
<p>(位运算符操作的是二进制数，将操作数转换二进制数后再进行运算，负数在计算机中以二进制补码的形式存在。符号位不变，原码取反后加一得出负数的补码。正数其实也是这样表示，只不过正数的原反补码都相同，不用进行转换。)</p>
<p>3.赋值运算符：=<br>(与其他运算符结合：+=，-=，*=，/=，%=，&amp;=，|=，^=，&lt;&lt;=，&gt;&gt;=，&gt;&gt;&gt;=)</p>
<p>4.比较运算符：&gt;，&gt;=，&lt;，&lt;=，==，!=（运算结果为布尔型：true or false）</p>
<p>5.逻辑运算符：&amp;&amp;，&amp;，||，|，！，^<br>(与，不短路与，或，不短路或，非，异或)<br>(&amp;&amp; 与 &amp;，|| 与 | 的区别：当 &amp;&amp; / || 左边的操作数为 false / true 时，不计算右边的操作数，直接返回 false / true。而 &amp; / | 两边的操作数都会计算。这便是不短路的意思。)</p>
<p>6.三目运算符 ： ? :<br>语法格式：(expression) ? (result1) : (result2)。expression为true返回result1，为false返回result2。<br>(三目运算符作用与if-else语句类似，运用得当能减少代码量)。</p>

    </div>

    
    
    

    <footer class="post-footer">

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2020/07/13/test/" rel="prev" title="test">
                  <i class="fa fa-chevron-left"></i> test
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2020/09/08/believe/" rel="next" title="believe">
                  believe <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
  
  
  



      

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      const commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

    </div>
  </main>

  <footer class="footer">
    <div class="footer-inner">
      

      

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">lungyam</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a>
  </div>

    </div>
  </footer>

  
  <script src="//cdn.jsdelivr.net/npm/animejs@3.2.0/lib/anime.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  


















  








  

  

</body>
</html>
